var fs = require('fs')
function readFile_promise(path) {
  return new Promise((resolve, reject) => {
    fs.readFile(path, (err, data) => {
      if (err) {
        reject(new Error('Error'))
      } else {
        resolve(data.toString())
      }
    })
  })
}
function *gen1() {
  var result1 = yield readFile_promise('../bar.txt')
  console.log(result1)
  var result2 = yield readFile_promise('../baz.txt')
}
var ge = gen1()
console.log(ge.next())
console.log(ge.next('aaa'))



async function gen() {
  var result1 = await readFile_promise('../bar.txt')
  console.log('result1', result1)
  var result2 = await readFile_promise('../baz.txt')
  console.log('result2', result2)
  return 'bbb'
}
console.log('gen_Promise', gen().then(res => console.log(res)))